
if exists (select 1
            from  sysobjects
           where  id = object_id('gen_table')
            and   type = 'U')
   drop table gen_table
go

if exists (select 1
            from  sysobjects
           where  id = object_id('gen_table_column')
            and   type = 'U')
   drop table gen_table_column
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_config')
            and   name  = 'uidx_config_key'
            and   indid > 0
            and   indid < 255)
   drop index sys_config.uidx_config_key
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_config')
            and   type = 'U')
   drop table sys_config
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_dept')
            and   type = 'U')
   drop table sys_dept
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_dict_data')
            and   type = 'U')
   drop table sys_dict_data
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_dict_type')
            and   name  = 'uidx_dict_type'
            and   indid > 0
            and   indid < 255)
   drop index sys_dict_type.uidx_dict_type
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_dict_type')
            and   type = 'U')
   drop table sys_dict_type
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_job')
            and   type = 'U')
   drop table sys_job
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_job_log')
            and   type = 'U')
   drop table sys_job_log
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_logininfor')
            and   name  = 'idx_user_name'
            and   indid > 0
            and   indid < 255)
   drop index sys_logininfor.idx_user_name
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_logininfor')
            and   type = 'U')
   drop table sys_logininfor
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_menu')
            and   type = 'U')
   drop table sys_menu
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_notice')
            and   name  = 'idx_create_time'
            and   indid > 0
            and   indid < 255)
   drop index sys_notice.idx_create_time
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_notice')
            and   type = 'U')
   drop table sys_notice
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_oper_log')
            and   name  = 'idx_oper_time'
            and   indid > 0
            and   indid < 255)
   drop index sys_oper_log.idx_oper_time
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_oper_log')
            and   type = 'U')
   drop table sys_oper_log
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_post')
            and   name  = 'uidx_post_code'
            and   indid > 0
            and   indid < 255)
   drop index sys_post.uidx_post_code
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_post')
            and   type = 'U')
   drop table sys_post
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_role')
            and   name  = 'uidx_role_key'
            and   indid > 0
            and   indid < 255)
   drop index sys_role.uidx_role_key
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_role')
            and   type = 'U')
   drop table sys_role
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_role_dept')
            and   type = 'U')
   drop table sys_role_dept
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_role_menu')
            and   type = 'U')
   drop table sys_role_menu
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('sys_user')
            and   name  = 'uidx_user_name'
            and   indid > 0
            and   indid < 255)
   drop index sys_user.uidx_user_name
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_user')
            and   type = 'U')
   drop table sys_user
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_user_post')
            and   type = 'U')
   drop table sys_user_post
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_user_role')
            and   type = 'U')
   drop table sys_user_role
go

/*==============================================================*/
/* Table: gen_table                                             */
/*==============================================================*/
create table gen_table (
   table_id             bigint               not null,
   table_name           nvarchar(200)         null,
   table_comment        nvarchar(500)         null,
   sub_table_name       nvarchar(64)          null,
   sub_table_fk_name    nvarchar(64)          null,
   class_name           nvarchar(100)         null,
   tpl_category         nvarchar(200)         null default 'crud',
   package_name         nvarchar(100)         null,
   module_name          nvarchar(30)          null,
   business_name        nvarchar(30)          null,
   function_name        nvarchar(50)          null,
   function_author      nvarchar(50)          null,
   gen_type             nchar(1)              null default '0',
   gen_path             nvarchar(200)         null default '/',
   options              nvarchar(1000)        null,
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_gen_table primary key nonclustered (table_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('gen_table') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'gen_table' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '代码生成业务表', 
   'user', 'dbo', 'table', 'gen_table'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'table_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'table_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '编号',
   'user', 'dbo', 'table', 'gen_table', 'column', 'table_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'table_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'table_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '表名称',
   'user', 'dbo', 'table', 'gen_table', 'column', 'table_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'table_comment')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'table_comment'

end


execute sp_addextendedproperty 'MS_Description', 
   '表描述',
   'user', 'dbo', 'table', 'gen_table', 'column', 'table_comment'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'sub_table_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'sub_table_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '关联子表的表名',
   'user', 'dbo', 'table', 'gen_table', 'column', 'sub_table_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'sub_table_fk_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'sub_table_fk_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '子表关联的外键名',
   'user', 'dbo', 'table', 'gen_table', 'column', 'sub_table_fk_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'class_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'class_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '实体类名称',
   'user', 'dbo', 'table', 'gen_table', 'column', 'class_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'tpl_category')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'tpl_category'

end


execute sp_addextendedproperty 'MS_Description', 
   '使用的模板（crud单表操作 tree树表操作）',
   'user', 'dbo', 'table', 'gen_table', 'column', 'tpl_category'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'package_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'package_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '生成包路径',
   'user', 'dbo', 'table', 'gen_table', 'column', 'package_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'module_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'module_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '生成模块名',
   'user', 'dbo', 'table', 'gen_table', 'column', 'module_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'business_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'business_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '生成业务名',
   'user', 'dbo', 'table', 'gen_table', 'column', 'business_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'function_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'function_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '生成功能名',
   'user', 'dbo', 'table', 'gen_table', 'column', 'function_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'function_author')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'function_author'

end


execute sp_addextendedproperty 'MS_Description', 
   '生成功能作者',
   'user', 'dbo', 'table', 'gen_table', 'column', 'function_author'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'gen_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'gen_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '生成代码方式（0zip压缩包 1自定义路径）',
   'user', 'dbo', 'table', 'gen_table', 'column', 'gen_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'gen_path')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'gen_path'

end


execute sp_addextendedproperty 'MS_Description', 
   '生成路径（不填默认项目路径）',
   'user', 'dbo', 'table', 'gen_table', 'column', 'gen_path'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'options')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'options'

end


execute sp_addextendedproperty 'MS_Description', 
   '其它生成选项',
   'user', 'dbo', 'table', 'gen_table', 'column', 'options'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'gen_table', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'gen_table', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'gen_table', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'gen_table', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'gen_table', 'column', 'remark'
go

/*==============================================================*/
/* Table: gen_table_column                                      */
/*==============================================================*/
create table gen_table_column (
   column_id            bigint               not null,
   table_id             bigint               null,
   column_name          nvarchar(200)         null,
   column_comment       nvarchar(500)         null,
   column_type          nvarchar(100)         null,
   column_length        int                  null,
   java_type            nvarchar(500)         null,
   java_field           nvarchar(200)         null,
   jdbc_type            int                  null,
   is_pk                nchar(1)              null,
   is_increment         nchar(1)              null,
   is_required          nchar(1)              null,
   is_insert            nchar(1)              null,
   is_edit              nchar(1)              null,
   is_list              nchar(1)              null,
   is_query             nchar(1)              null,
   query_type           nvarchar(200)         null default 'EQ',
   html_type            nvarchar(200)         null,
   dict_type            nvarchar(200)         null,
   sort                 int                  null,
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   constraint PK_gen_table_column primary key nonclustered (column_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('gen_table_column') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'gen_table_column' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '代码生成业务表字段', 
   'user', 'dbo', 'table', 'gen_table_column'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'column_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '编号',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'table_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'table_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '归属表编号',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'table_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'column_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '列名称',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'column_comment')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_comment'

end


execute sp_addextendedproperty 'MS_Description', 
   '列描述',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_comment'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'column_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '列类型',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'column_length')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_length'

end


execute sp_addextendedproperty 'MS_Description', 
   '列长度',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'column_length'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'java_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'java_type'

end


execute sp_addextendedproperty 'MS_Description', 
   'JAVA类型',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'java_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'java_field')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'java_field'

end


execute sp_addextendedproperty 'MS_Description', 
   'JAVA字段名',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'java_field'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'jdbc_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'jdbc_type'

end


execute sp_addextendedproperty 'MS_Description', 
   'JDBC类型',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'jdbc_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_pk')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_pk'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否主键（1是）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_pk'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_increment')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_increment'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否自增（1是）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_increment'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_required')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_required'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否必填（1是）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_required'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_insert')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_insert'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否为插入字段（1是）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_insert'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_edit')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_edit'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否编辑字段（1是）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_edit'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_list')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_list'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否列表字段（1是）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_list'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_query')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_query'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否查询字段（1是）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'is_query'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'query_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'query_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '查询方式（等于、不等于、大于、小于、范围）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'query_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'html_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'html_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '显示类型（文本框、文本域、下拉框、复选框、单选框、日期控件）',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'html_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'dict_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典类型',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'dict_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'sort')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'sort'

end


execute sp_addextendedproperty 'MS_Description', 
   '排序',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'sort'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('gen_table_column')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'gen_table_column', 'column', 'update_time'
go

/*==============================================================*/
/* Table: sys_config                                            */
/*==============================================================*/
create table sys_config (
   config_id            bigint               not null,
   config_name          nvarchar(100)         null,
   config_key           nvarchar(100)         null,
   config_value         nvarchar(500)         null,
   config_type          nchar(1)              null default 'N',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_config primary key nonclustered (config_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_config') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_config' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '参数配置表', 
   'user', 'dbo', 'table', 'sys_config'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'config_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '参数主键',
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'config_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '参数名称',
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'config_key')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_key'

end


execute sp_addextendedproperty 'MS_Description', 
   '参数键名',
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_key'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'config_value')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_value'

end


execute sp_addextendedproperty 'MS_Description', 
   '参数键值',
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_value'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'config_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '系统内置（Y是 N否）',
   'user', 'dbo', 'table', 'sys_config', 'column', 'config_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_config', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_config', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_config', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_config', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_config')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_config', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_config', 'column', 'remark'
go

/*==============================================================*/
/* Index: uidx_config_key                                       */
/*==============================================================*/
create unique index uidx_config_key on sys_config (
config_key ASC
)
go

/*==============================================================*/
/* Table: sys_dept                                              */
/*==============================================================*/
create table sys_dept (
   dept_id              bigint               not null,
   parent_id            bigint               null default 0,
   ancestors            nvarchar(50)          null,
   dept_name            nvarchar(30)          null,
   order_num            int                  null default 0,
   leader               nvarchar(20)          null,
   phone                nvarchar(11)          null,
   email                nvarchar(50)          null,
   status               nchar(1)              null default '0',
   del_flag             nchar(1)              null default '0',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   constraint PK_sys_dept primary key nonclustered (dept_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_dept') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_dept' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '部门表', 
   'user', 'dbo', 'table', 'sys_dept'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dept_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'dept_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '部门id',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'dept_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'parent_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'parent_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '父部门id',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'parent_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ancestors')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'ancestors'

end


execute sp_addextendedproperty 'MS_Description', 
   '祖级列表',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'ancestors'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dept_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'dept_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '部门名称',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'dept_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'order_num')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'order_num'

end


execute sp_addextendedproperty 'MS_Description', 
   '显示顺序',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'order_num'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'leader')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'leader'

end


execute sp_addextendedproperty 'MS_Description', 
   '负责人',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'leader'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'phone')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'phone'

end


execute sp_addextendedproperty 'MS_Description', 
   '联系电话',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'phone'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'email')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'email'

end


execute sp_addextendedproperty 'MS_Description', 
   '邮箱',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'email'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '部门状态（0正常 1停用）',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'del_flag')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'del_flag'

end


execute sp_addextendedproperty 'MS_Description', 
   '删除标志（0代表存在 2代表删除）',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'del_flag'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dept', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_dept', 'column', 'update_time'
go

/*==============================================================*/
/* Table: sys_dict_data                                         */
/*==============================================================*/
create table sys_dict_data (
   dict_code            bigint               not null,
   dict_sort            int                  null default 0,
   dict_label           nvarchar(100)         null,
   dict_value           nvarchar(100)         null,
   dict_type            nvarchar(100)         null,
   css_class            nvarchar(100)         null,
   list_class           nvarchar(100)         null,
   is_default           nchar(1)              null default 'N',
   status               nchar(1)              null default '0',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_dict_data primary key nonclustered (dict_code)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_dict_data') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_dict_data' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '字典数据表', 
   'user', 'dbo', 'table', 'sys_dict_data'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_code')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_code'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典编码',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_code'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_sort')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_sort'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典排序',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_sort'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_label')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_label'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典标签',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_label'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_value')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_value'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典键值',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_value'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典类型',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'dict_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'css_class')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'css_class'

end


execute sp_addextendedproperty 'MS_Description', 
   '样式属性（其他样式扩展）',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'css_class'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'list_class')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'list_class'

end


execute sp_addextendedproperty 'MS_Description', 
   '表格回显样式',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'list_class'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_default')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'is_default'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否默认（Y是 N否）',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'is_default'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '状态（0正常 1停用）',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_data')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_dict_data', 'column', 'remark'
go

/*==============================================================*/
/* Table: sys_dict_type                                         */
/*==============================================================*/
create table sys_dict_type (
   dict_id              bigint               not null,
   dict_name            nvarchar(100)         null,
   dict_type            nvarchar(100)         null,
   status               nchar(1)              null default '0',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_dict_type primary key nonclustered (dict_id),
   constraint dict_type unique (dict_type)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_dict_type') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_dict_type' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '字典类型表', 
   'user', 'dbo', 'table', 'sys_dict_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'dict_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典主键',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'dict_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'dict_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典名称',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'dict_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dict_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'dict_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '字典类型',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'dict_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '状态（0正常 1停用）',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_dict_type')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_dict_type', 'column', 'remark'
go

/*==============================================================*/
/* Index: uidx_dict_type                                        */
/*==============================================================*/
create unique index uidx_dict_type on sys_dict_type (
dict_type ASC
)
go

/*==============================================================*/
/* Table: sys_job                                               */
/*==============================================================*/
create table sys_job (
   job_id               bigint               not null,
   job_name             nvarchar(64)          not null,
   job_group            nvarchar(64)          not null default 'DEFAULT',
   invoke_target        nvarchar(500)         not null,
   cron_expression      nvarchar(255)         null,
   misfire_policy       nvarchar(20)          null default '3',
   concurrent           nchar(1)              null default '1',
   status               nchar(1)              null default '0',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_job primary key nonclustered (job_id, job_name, job_group)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_job') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_job' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '定时任务调度表', 
   'user', 'dbo', 'table', 'sys_job'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'job_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'job_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务ID',
   'user', 'dbo', 'table', 'sys_job', 'column', 'job_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'job_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'job_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务名称',
   'user', 'dbo', 'table', 'sys_job', 'column', 'job_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'job_group')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'job_group'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务组名',
   'user', 'dbo', 'table', 'sys_job', 'column', 'job_group'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'invoke_target')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'invoke_target'

end


execute sp_addextendedproperty 'MS_Description', 
   '调用目标字符串',
   'user', 'dbo', 'table', 'sys_job', 'column', 'invoke_target'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'cron_expression')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'cron_expression'

end


execute sp_addextendedproperty 'MS_Description', 
   'cron执行表达式',
   'user', 'dbo', 'table', 'sys_job', 'column', 'cron_expression'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'misfire_policy')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'misfire_policy'

end


execute sp_addextendedproperty 'MS_Description', 
   '计划执行错误策略（1立即执行 2执行一次 3放弃执行）',
   'user', 'dbo', 'table', 'sys_job', 'column', 'misfire_policy'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'concurrent')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'concurrent'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否并发执行（0允许 1禁止）',
   'user', 'dbo', 'table', 'sys_job', 'column', 'concurrent'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '状态（0正常 1暂停）',
   'user', 'dbo', 'table', 'sys_job', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_job', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_job', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_job', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_job', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注信息',
   'user', 'dbo', 'table', 'sys_job', 'column', 'remark'
go

/*==============================================================*/
/* Table: sys_job_log                                           */
/*==============================================================*/
create table sys_job_log (
   job_log_id           bigint               not null,
   job_name             nvarchar(64)          not null,
   job_group            nvarchar(64)          not null,
   invoke_target        nvarchar(500)         not null,
   job_message          nvarchar(500)         null,
   status               nchar(1)              null default '0',
   exception_info       nvarchar(2000)        null,
   start_time           datetime             null,
   stop_time            datetime             null,
   create_time          datetime             null,
   constraint PK_sys_job_log primary key nonclustered (job_log_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_job_log') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_job_log' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '定时任务调度日志表', 
   'user', 'dbo', 'table', 'sys_job_log'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'job_log_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_log_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务日志ID',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_log_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'job_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务名称',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'job_group')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_group'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务组名',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_group'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'invoke_target')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'invoke_target'

end


execute sp_addextendedproperty 'MS_Description', 
   '调用目标字符串',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'invoke_target'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'job_message')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_message'

end


execute sp_addextendedproperty 'MS_Description', 
   '日志信息',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'job_message'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '执行状态（0正常 1失败）',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'exception_info')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'exception_info'

end


execute sp_addextendedproperty 'MS_Description', 
   '异常信息',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'exception_info'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'start_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'start_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务开始时间',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'start_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'stop_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'stop_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '任务结束时间',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'stop_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_job_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_job_log', 'column', 'create_time'
go

/*==============================================================*/
/* Table: sys_logininfor                                        */
/*==============================================================*/
create table sys_logininfor (
   info_id              bigint               not null,
   user_name            nvarchar(50)          null,
   ipaddr               nvarchar(128)         null,
   login_location       nvarchar(255)         null,
   browser              nvarchar(50)          null,
   os                   nvarchar(50)          null,
   status               nchar(1)              null default '0',
   msg                  nvarchar(255)         null,
   login_time           datetime             null,
   constraint PK_sys_logininfor primary key nonclustered (info_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_logininfor') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_logininfor' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '系统访问记录', 
   'user', 'dbo', 'table', 'sys_logininfor'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'info_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'info_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '访问ID',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'info_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'user_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'user_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户账号',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'user_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ipaddr')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'ipaddr'

end


execute sp_addextendedproperty 'MS_Description', 
   '登录IP地址',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'ipaddr'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'login_location')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'login_location'

end


execute sp_addextendedproperty 'MS_Description', 
   '登录地点',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'login_location'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'browser')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'browser'

end


execute sp_addextendedproperty 'MS_Description', 
   '浏览器类型',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'browser'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'os')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'os'

end


execute sp_addextendedproperty 'MS_Description', 
   '操作系统',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'os'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '登录状态（0成功 1失败）',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'msg')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'msg'

end


execute sp_addextendedproperty 'MS_Description', 
   '提示消息',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'msg'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_logininfor')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'login_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'login_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '访问时间',
   'user', 'dbo', 'table', 'sys_logininfor', 'column', 'login_time'
go

/*==============================================================*/
/* Index: idx_user_name                                         */
/*==============================================================*/
create index idx_user_name on sys_logininfor (
user_name ASC
)
go

/*==============================================================*/
/* Table: sys_menu                                              */
/*==============================================================*/
create table sys_menu (
   menu_id              bigint               not null,
   menu_name            nvarchar(50)          not null,
   parent_id            bigint               null default 0,
   order_num            int                  null default 0,
   path                 nvarchar(200)         null,
   component            nvarchar(255)         null,
   is_frame             int                  null default 1,
   is_cache             int                  null default 0,
   menu_type            nchar(1)              null,
   visible              nchar(1)              null default '0',
   status               nchar(1)              null default '0',
   perms                nvarchar(100)         null,
   icon                 nvarchar(100)         null default '#',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_menu primary key nonclustered (menu_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_menu') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_menu' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '菜单权限表', 
   'user', 'dbo', 'table', 'sys_menu'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'menu_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'menu_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单ID',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'menu_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'menu_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'menu_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单名称',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'menu_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'parent_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'parent_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '父菜单ID',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'parent_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'order_num')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'order_num'

end


execute sp_addextendedproperty 'MS_Description', 
   '显示顺序',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'order_num'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'path')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'path'

end


execute sp_addextendedproperty 'MS_Description', 
   '路由地址',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'path'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'component')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'component'

end


execute sp_addextendedproperty 'MS_Description', 
   '组件路径',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'component'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_frame')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'is_frame'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否为外链（0是 1否）',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'is_frame'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'is_cache')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'is_cache'

end


execute sp_addextendedproperty 'MS_Description', 
   '是否缓存（0缓存 1不缓存）',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'is_cache'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'menu_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'menu_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单类型（M目录 C菜单 F按钮）',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'menu_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'visible')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'visible'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单状态（0显示 1隐藏）',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'visible'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单状态（0正常 1停用）',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'perms')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'perms'

end


execute sp_addextendedproperty 'MS_Description', 
   '权限标识',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'perms'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'icon')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'icon'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单图标',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'icon'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_menu', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_menu', 'column', 'remark'
go

/*==============================================================*/
/* Table: sys_notice                                            */
/*==============================================================*/
create table sys_notice (
   notice_id            bigint               not null,
   notice_title         nvarchar(50)          not null,
   notice_type          nchar(1)              not null,
   notice_content       text                 null,
   status               nchar(1)              null default '0',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(255)         null,
   constraint PK_sys_notice primary key nonclustered (notice_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_notice') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_notice' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '通知公告表', 
   'user', 'dbo', 'table', 'sys_notice'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'notice_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '公告ID',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'notice_title')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_title'

end


execute sp_addextendedproperty 'MS_Description', 
   '公告标题',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_title'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'notice_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '公告类型（1通知 2公告）',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'notice_content')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_content'

end


execute sp_addextendedproperty 'MS_Description', 
   '公告内容',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'notice_content'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '公告状态（0正常 1关闭）',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_notice')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_notice', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_notice', 'column', 'remark'
go

/*==============================================================*/
/* Index: idx_create_time                                       */
/*==============================================================*/
create index idx_create_time on sys_notice (
create_time ASC
)
go

/*==============================================================*/
/* Table: sys_oper_log                                          */
/*==============================================================*/
create table sys_oper_log (
   oper_id              bigint               not null,
   title                nvarchar(50)          null,
   business_type        int                  null default 0,
   method               nvarchar(100)         null,
   request_method       nvarchar(10)          null,
   operator_type        int                  null default 0,
   oper_name            nvarchar(50)          null,
   dept_name            nvarchar(50)          null,
   oper_url             nvarchar(255)         null,
   oper_ip              nvarchar(128)         null,
   oper_location        nvarchar(255)         null,
   oper_param           nvarchar(2000)        null,
   json_result          nvarchar(2000)        null,
   status               int                  null default 0,
   error_msg            nvarchar(2000)        null,
   oper_time            datetime             null,
   constraint PK_sys_oper_log primary key nonclustered (oper_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_oper_log') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_oper_log' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '操作日志记录', 
   'user', 'dbo', 'table', 'sys_oper_log'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'oper_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '日志主键',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'title')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'title'

end


execute sp_addextendedproperty 'MS_Description', 
   '模块标题',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'title'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'business_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'business_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '业务类型（0其它 1新增 2修改 3删除）',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'business_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'method')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'method'

end


execute sp_addextendedproperty 'MS_Description', 
   '方法名称',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'method'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'request_method')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'request_method'

end


execute sp_addextendedproperty 'MS_Description', 
   '请求方式',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'request_method'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'operator_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'operator_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '操作类别（0其它 1后台用户 2手机端用户）',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'operator_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'oper_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '操作人员',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dept_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'dept_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '部门名称',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'dept_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'oper_url')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_url'

end


execute sp_addextendedproperty 'MS_Description', 
   '请求URL',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_url'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'oper_ip')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_ip'

end


execute sp_addextendedproperty 'MS_Description', 
   '主机地址',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_ip'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'oper_location')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_location'

end


execute sp_addextendedproperty 'MS_Description', 
   '操作地点',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_location'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'oper_param')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_param'

end


execute sp_addextendedproperty 'MS_Description', 
   '请求参数',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_param'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'json_result')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'json_result'

end


execute sp_addextendedproperty 'MS_Description', 
   '返回参数',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'json_result'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '操作状态（0正常 1异常）',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'error_msg')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'error_msg'

end


execute sp_addextendedproperty 'MS_Description', 
   '错误消息',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'error_msg'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_oper_log')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'oper_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '操作时间',
   'user', 'dbo', 'table', 'sys_oper_log', 'column', 'oper_time'
go

/*==============================================================*/
/* Index: idx_oper_time                                         */
/*==============================================================*/
create index idx_oper_time on sys_oper_log (
oper_time ASC
)
go

/*==============================================================*/
/* Table: sys_post                                              */
/*==============================================================*/
create table sys_post (
   post_id              bigint               not null,
   post_code            nvarchar(64)          not null,
   post_name            nvarchar(50)          not null,
   post_sort            int                  not null,
   status               nchar(1)              not null,
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_post primary key nonclustered (post_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_post') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_post' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '岗位信息表', 
   'user', 'dbo', 'table', 'sys_post'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'post_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '岗位ID',
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'post_code')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_code'

end


execute sp_addextendedproperty 'MS_Description', 
   '岗位编码',
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_code'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'post_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '岗位名称',
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'post_sort')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_sort'

end


execute sp_addextendedproperty 'MS_Description', 
   '显示顺序',
   'user', 'dbo', 'table', 'sys_post', 'column', 'post_sort'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '状态（0正常 1停用）',
   'user', 'dbo', 'table', 'sys_post', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_post', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_post', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_post', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_post', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_post', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_post', 'column', 'remark'
go

/*==============================================================*/
/* Index: uidx_post_code                                        */
/*==============================================================*/
create unique index uidx_post_code on sys_post (
post_code ASC
)
go

/*==============================================================*/
/* Table: sys_role                                              */
/*==============================================================*/
create table sys_role (
   role_id              bigint               not null,
   role_name            nvarchar(30)          not null,
   role_key             nvarchar(100)         not null,
   role_sort            int                  not null,
   data_scope           nchar(1)              null default '1',
   menu_check_strictly  tinyint              null default 1,
   dept_check_strictly  tinyint              null default 1,
   status               nchar(1)              not null,
   del_flag             nchar(1)              null default '0',
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_role primary key nonclustered (role_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_role') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_role' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '角色信息表', 
   'user', 'dbo', 'table', 'sys_role'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'role_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '角色ID',
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'role_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '角色名称',
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'role_key')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_key'

end


execute sp_addextendedproperty 'MS_Description', 
   '角色权限字符串',
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_key'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'role_sort')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_sort'

end


execute sp_addextendedproperty 'MS_Description', 
   '显示顺序',
   'user', 'dbo', 'table', 'sys_role', 'column', 'role_sort'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'data_scope')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'data_scope'

end


execute sp_addextendedproperty 'MS_Description', 
   '数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）',
   'user', 'dbo', 'table', 'sys_role', 'column', 'data_scope'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'menu_check_strictly')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'menu_check_strictly'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单树选择项是否关联显示',
   'user', 'dbo', 'table', 'sys_role', 'column', 'menu_check_strictly'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dept_check_strictly')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'dept_check_strictly'

end


execute sp_addextendedproperty 'MS_Description', 
   '部门树选择项是否关联显示',
   'user', 'dbo', 'table', 'sys_role', 'column', 'dept_check_strictly'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '角色状态（0正常 1停用）',
   'user', 'dbo', 'table', 'sys_role', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'del_flag')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'del_flag'

end


execute sp_addextendedproperty 'MS_Description', 
   '删除标志（0代表存在 2代表删除）',
   'user', 'dbo', 'table', 'sys_role', 'column', 'del_flag'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_role', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_role', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_role', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_role', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_role', 'column', 'remark'
go

/*==============================================================*/
/* Index: uidx_role_key                                         */
/*==============================================================*/
create unique index uidx_role_key on sys_role (
role_key ASC
)
go

/*==============================================================*/
/* Table: sys_role_dept                                         */
/*==============================================================*/
create table sys_role_dept (
   role_id              bigint               not null,
   dept_id              bigint               not null,
   constraint PK_sys_role_dept primary key nonclustered (role_id, dept_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_role_dept') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_role_dept' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '角色和部门关联表', 
   'user', 'dbo', 'table', 'sys_role_dept'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'role_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role_dept', 'column', 'role_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '角色ID',
   'user', 'dbo', 'table', 'sys_role_dept', 'column', 'role_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role_dept')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dept_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role_dept', 'column', 'dept_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '部门ID',
   'user', 'dbo', 'table', 'sys_role_dept', 'column', 'dept_id'
go

/*==============================================================*/
/* Table: sys_role_menu                                         */
/*==============================================================*/
create table sys_role_menu (
   role_id              bigint               not null,
   menu_id              bigint               not null,
   constraint PK_sys_role_menu primary key nonclustered (role_id, menu_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_role_menu') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_role_menu' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '角色和菜单关联表', 
   'user', 'dbo', 'table', 'sys_role_menu'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'role_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role_menu', 'column', 'role_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '角色ID',
   'user', 'dbo', 'table', 'sys_role_menu', 'column', 'role_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_role_menu')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'menu_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_role_menu', 'column', 'menu_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '菜单ID',
   'user', 'dbo', 'table', 'sys_role_menu', 'column', 'menu_id'
go

/*==============================================================*/
/* Table: sys_user                                              */
/*==============================================================*/
create table sys_user (
   user_id              bigint               not null,
   dept_id              bigint               null,
   user_name            nvarchar(30)          not null,
   nick_name            nvarchar(30)          not null,
   user_type            nvarchar(2)           null default '00',
   email                nvarchar(50)          null,
   phonenumber          nvarchar(11)          null,
   sex                  nchar(1)              null default '0',
   avatar               nvarchar(100)         null,
   password             nvarchar(100)         null,
   status               nchar(1)              null default '0',
   del_flag             nchar(1)              null default '0',
   login_ip             nvarchar(128)         null,
   login_date           datetime             null,
   create_by            nvarchar(64)          null,
   create_time          datetime             null,
   update_by            nvarchar(64)          null,
   update_time          datetime             null,
   remark               nvarchar(500)         null,
   constraint PK_sys_user primary key nonclustered (user_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_user') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_user' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '用户信息表', 
   'user', 'dbo', 'table', 'sys_user'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'user_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'user_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户ID',
   'user', 'dbo', 'table', 'sys_user', 'column', 'user_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'dept_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'dept_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '部门ID',
   'user', 'dbo', 'table', 'sys_user', 'column', 'dept_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'user_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'user_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户账号',
   'user', 'dbo', 'table', 'sys_user', 'column', 'user_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'nick_name')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'nick_name'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户昵称',
   'user', 'dbo', 'table', 'sys_user', 'column', 'nick_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'user_type')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'user_type'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户类型（00系统用户）',
   'user', 'dbo', 'table', 'sys_user', 'column', 'user_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'email')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'email'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户邮箱',
   'user', 'dbo', 'table', 'sys_user', 'column', 'email'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'phonenumber')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'phonenumber'

end


execute sp_addextendedproperty 'MS_Description', 
   '手机号码',
   'user', 'dbo', 'table', 'sys_user', 'column', 'phonenumber'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'sex')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'sex'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户性别（0男 1女 2未知）',
   'user', 'dbo', 'table', 'sys_user', 'column', 'sex'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'avatar')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'avatar'

end


execute sp_addextendedproperty 'MS_Description', 
   '头像地址',
   'user', 'dbo', 'table', 'sys_user', 'column', 'avatar'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'password')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'password'

end


execute sp_addextendedproperty 'MS_Description', 
   '密码',
   'user', 'dbo', 'table', 'sys_user', 'column', 'password'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'status')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'status'

end


execute sp_addextendedproperty 'MS_Description', 
   '帐号状态（0正常 1停用）',
   'user', 'dbo', 'table', 'sys_user', 'column', 'status'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'del_flag')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'del_flag'

end


execute sp_addextendedproperty 'MS_Description', 
   '删除标志（0代表存在 2代表删除）',
   'user', 'dbo', 'table', 'sys_user', 'column', 'del_flag'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'login_ip')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'login_ip'

end


execute sp_addextendedproperty 'MS_Description', 
   '最后登录IP',
   'user', 'dbo', 'table', 'sys_user', 'column', 'login_ip'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'login_date')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'login_date'

end


execute sp_addextendedproperty 'MS_Description', 
   '最后登录时间',
   'user', 'dbo', 'table', 'sys_user', 'column', 'login_date'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'create_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建者',
   'user', 'dbo', 'table', 'sys_user', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'create_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '创建时间',
   'user', 'dbo', 'table', 'sys_user', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'update_by'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新者',
   'user', 'dbo', 'table', 'sys_user', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'update_time'

end


execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', 'dbo', 'table', 'sys_user', 'column', 'update_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'remark')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user', 'column', 'remark'

end


execute sp_addextendedproperty 'MS_Description', 
   '备注',
   'user', 'dbo', 'table', 'sys_user', 'column', 'remark'
go

/*==============================================================*/
/* Index: uidx_user_name                                        */
/*==============================================================*/
create unique index uidx_user_name on sys_user (
user_name ASC
)
go

/*==============================================================*/
/* Table: sys_user_post                                         */
/*==============================================================*/
create table sys_user_post (
   user_id              bigint               not null,
   post_id              bigint               not null,
   constraint PK_sys_user_post primary key nonclustered (user_id, post_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_user_post') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_user_post' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '用户与岗位关联表', 
   'user', 'dbo', 'table', 'sys_user_post'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'user_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user_post', 'column', 'user_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户ID',
   'user', 'dbo', 'table', 'sys_user_post', 'column', 'user_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user_post')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'post_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user_post', 'column', 'post_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '岗位ID',
   'user', 'dbo', 'table', 'sys_user_post', 'column', 'post_id'
go

/*==============================================================*/
/* Table: sys_user_role                                         */
/*==============================================================*/
create table sys_user_role (
   user_id              bigint               not null,
   role_id              bigint               not null,
   constraint PK_sys_user_role primary key nonclustered (user_id, role_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('sys_user_role') and minor_id = 0)
begin 
   execute sp_dropextendedproperty 'MS_Description',  
   'user', 'dbo', 'table', 'sys_user_role' 
 
end 


execute sp_addextendedproperty 'MS_Description',  
   '用户和角色关联表', 
   'user', 'dbo', 'table', 'sys_user_role'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'user_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user_role', 'column', 'user_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '用户ID',
   'user', 'dbo', 'table', 'sys_user_role', 'column', 'user_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('sys_user_role')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'role_id')
)
begin
   execute sp_dropextendedproperty 'MS_Description', 
   'user', 'dbo', 'table', 'sys_user_role', 'column', 'role_id'

end


execute sp_addextendedproperty 'MS_Description', 
   '角色ID',
   'user', 'dbo', 'table', 'sys_user_role', 'column', 'role_id'
go

-- 数据

INSERT INTO "sys_config" ("config_id", "config_name", "config_key", "config_value", "config_type", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', '2021-05-23 10:02:55', '', NULL, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow'),
	(2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', '2021-05-23 10:02:55', '', NULL, '初始化密码 123456'),
	(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', '2021-05-23 10:02:55', '', NULL, '深色主题theme-dark，浅色主题theme-light');

INSERT INTO "sys_dept" ("dept_id", "parent_id", "ancestors", "dept_name", "order_num", "leader", "phone", "email", "status", "del_flag", "create_by", "create_time", "update_by", "update_time") VALUES
	(100, 0, ':0:', '演示集团', 0, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', 'admin', '2021-06-06 11:07:09'),
	(101, 100, ':0:100:', '深圳总公司', 1, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(102, 100, ':0:100:', '长沙分公司', 2, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(103, 101, ':0:100:101:', '研发部门', 1, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(104, 101, ':0:100:101:', '市场部门', 2, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(105, 101, ':0:100:101:', '测试部门', 3, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(106, 101, ':0:100:101:', '财务部门', 4, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(107, 101, ':0:100:101:', '运维部门', 5, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(108, 102, ':0:100:102:', '市场部门', 1, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(109, 102, ':0:100:102:', '财务部门', 2, 'yadmin', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL),
	(200, 100, ':0:100:', '广州分公司', 3, '张三', '18520137214', NULL, '0', '0', 'admin', '2021-06-06 11:06:50', 'admin', '2021-06-06 11:06:50');

INSERT INTO "sys_dict_data" ("dict_code", "dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, 1, '男', '0', 'sys_user_sex', '', '', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '性别男'),
	(2, 2, '女', '1', 'sys_user_sex', '', '', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '性别女'),
	(3, 3, '未知', '2', 'sys_user_sex', '', '', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '性别未知'),
	(4, 1, '显示', '0', 'sys_show_hide', '', 'primary', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '显示菜单'),
	(5, 2, '隐藏', '1', 'sys_show_hide', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '隐藏菜单'),
	(6, 1, '正常', '0', 'sys_normal_disable', '', 'primary', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '正常状态'),
	(7, 2, '停用', '1', 'sys_normal_disable', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '停用状态'),
	(8, 1, '正常', '0', 'sys_job_status', '', 'primary', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '正常状态'),
	(9, 2, '暂停', '1', 'sys_job_status', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '停用状态'),
	(10, 1, '默认', 'DEFAULT', 'sys_job_group', '', '', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '默认分组'),
	(11, 2, '系统', 'SYSTEM', 'sys_job_group', '', '', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '系统分组'),
	(12, 1, '是', 'Y', 'sys_yes_no', '', 'primary', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '系统默认是'),
	(13, 2, '否', 'N', 'sys_yes_no', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '系统默认否'),
	(14, 1, '通知', '1', 'sys_notice_type', '', 'warning', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '通知'),
	(15, 2, '公告', '2', 'sys_notice_type', '', 'success', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '公告'),
	(16, 1, '正常', '0', 'sys_notice_status', '', 'primary', 'Y', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '正常状态'),
	(17, 2, '关闭', '1', 'sys_notice_status', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '关闭状态'),
	(18, 1, '新增', '1', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '新增操作'),
	(19, 2, '修改', '2', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '修改操作'),
	(20, 3, '删除', '3', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '删除操作'),
	(21, 4, '授权', '4', 'sys_oper_type', '', 'primary', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '授权操作'),
	(22, 5, '导出', '5', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '导出操作'),
	(23, 6, '导入', '6', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '导入操作'),
	(24, 7, '强退', '7', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '强退操作'),
	(25, 8, '生成代码', '8', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '生成操作'),
	(26, 9, '清空数据', '9', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '清空操作'),
	(27, 1, '成功', '0', 'sys_common_status', '', 'primary', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '正常状态'),
	(28, 2, '失败', '1', 'sys_common_status', '', 'danger', 'N', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '停用状态');

INSERT INTO "sys_dict_type" ("dict_id", "dict_name", "dict_type", "status", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, '用户性别', 'sys_user_sex', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '用户性别列表'),
	(2, '菜单状态', 'sys_show_hide', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '菜单状态列表'),
	(3, '系统开关', 'sys_normal_disable', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '系统开关列表'),
	(4, '任务状态', 'sys_job_status', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '任务状态列表'),
	(5, '任务分组', 'sys_job_group', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '任务分组列表'),
	(6, '系统是否', 'sys_yes_no', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '系统是否列表'),
	(7, '通知类型', 'sys_notice_type', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '通知类型列表'),
	(8, '通知状态', 'sys_notice_status', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '通知状态列表'),
	(9, '操作类型', 'sys_oper_type', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '操作类型列表'),
	(10, '系统状态', 'sys_common_status', '0', 'admin', '2021-05-23 10:02:55', '', NULL, '登录状态列表');

INSERT INTO "sys_job" ("job_id", "job_name", "job_group", "invoke_target", "cron_expression", "misfire_policy", "concurrent", "status", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, '系统默认（无参）', 'DEFAULT', 'ryTask.ryNoParams', '0/10 * * * * ?', '3', '1', '1', 'admin', '2021-05-23 10:02:55', '', '2021-06-06 22:26:01', ''),
	(2, '系统默认（有参）', 'DEFAULT', 'ryTask.ryParams(''ry'')', '0/15 * * * * ?', '3', '1', '1', 'admin', '2021-05-23 10:02:55', '', NULL, ''),
	(3, '系统默认（多参）', 'DEFAULT', 'ryTask.ryMultipleParams(''ry'', true, 2000L, 316.50D, 100)', '0/20 * * * * ?', '3', '1', '1', 'admin', '2021-05-23 10:02:55', '', NULL, '');

INSERT INTO "sys_menu" ("menu_id", "menu_name", "parent_id", "order_num", "path", "component", "is_frame", "is_cache", "menu_type", "visible", "status", "perms", "icon", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, '系统管理', 0, 1, 'system', NULL, 1, 0, 'M', '0', '0', '', 'system', 'admin', '2021-05-23 10:02:51', '', NULL, '系统管理目录'),
	(2, '系统监控', 0, 2, 'monitor', NULL, 1, 0, 'M', '0', '0', '', 'monitor', 'admin', '2021-05-23 10:02:51', '', NULL, '系统监控目录'),
	(3, '系统工具', 0, 3, 'tool', NULL, 1, 0, 'M', '0', '0', '', 'tool', 'admin', '2021-05-23 10:02:51', '', NULL, '系统工具目录'),
	(100, '用户管理', 1, 1, 'user', 'system/user/index', 1, 0, 'C', '0', '0', 'system:user:list', 'user', 'admin', '2021-05-23 10:02:51', '', NULL, '用户管理菜单'),
	(101, '角色管理', 1, 2, 'role', 'system/role/index', 1, 0, 'C', '0', '0', 'system:role:list', 'peoples', 'admin', '2021-05-23 10:02:51', '', NULL, '角色管理菜单'),
	(102, '菜单管理', 1, 3, 'menu', 'system/menu/index', 1, 0, 'C', '0', '0', 'system:menu:list', 'tree-table', 'admin', '2021-05-23 10:02:51', '', NULL, '菜单管理菜单'),
	(103, '部门管理', 1, 4, 'dept', 'system/dept/index', 1, 0, 'C', '0', '0', 'system:dept:list', 'tree', 'admin', '2021-05-23 10:02:51', '', NULL, '部门管理菜单'),
	(104, '岗位管理', 1, 5, 'post', 'system/post/index', 1, 0, 'C', '0', '0', 'system:post:list', 'post', 'admin', '2021-05-23 10:02:51', '', NULL, '岗位管理菜单'),
	(105, '字典管理', 1, 6, 'dict', 'system/dict/index', 1, 0, 'C', '0', '0', 'system:dict:list', 'dict', 'admin', '2021-05-23 10:02:51', '', NULL, '字典管理菜单'),
	(106, '参数设置', 1, 7, 'config', 'system/config/index', 1, 0, 'C', '0', '0', 'system:config:list', 'edit', 'admin', '2021-05-23 10:02:51', '', NULL, '参数设置菜单'),
	(107, '通知公告', 1, 8, 'notice', 'system/notice/index', 1, 0, 'C', '0', '0', 'system:notice:list', 'message', 'admin', '2021-05-23 10:02:51', '', NULL, '通知公告菜单'),
	(108, '日志管理', 1, 9, 'log', '', 1, 0, 'M', '0', '0', '', 'log', 'admin', '2021-05-23 10:02:51', '', NULL, '日志管理菜单'),
	(109, '在线用户', 2, 1, 'online', 'monitor/online/index', 1, 0, 'C', '0', '0', 'monitor:online:list', 'online', 'admin', '2021-05-23 10:02:51', '', NULL, '在线用户菜单'),
	(110, '定时任务', 2, 2, 'job', 'monitor/job/index', 1, 0, 'C', '0', '0', 'monitor:job:list', 'job', 'admin', '2021-05-23 10:02:51', '', NULL, '定时任务菜单'),
	(111, '数据监控', 2, 3, 'druid', 'monitor/druid/index', 1, 0, 'C', '0', '0', 'monitor:druid:list', 'druid', 'admin', '2021-05-23 10:02:51', '', NULL, '数据监控菜单'),
	(112, '服务监控', 2, 4, 'server', 'monitor/server/index', 1, 0, 'C', '0', '0', 'monitor:server:list', 'server', 'admin', '2021-05-23 10:02:51', '', NULL, '服务监控菜单'),
	(113, '缓存监控', 2, 5, 'cache', 'monitor/cache/index', 1, 0, 'C', '0', '0', 'monitor:cache:list', 'redis', 'admin', '2021-05-23 10:02:51', '', NULL, '缓存监控菜单'),
	(114, '表单构建', 3, 1, 'build', 'tool/build/index', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', '2021-05-23 10:02:51', '', NULL, '表单构建菜单'),
	(115, '代码生成', 3, 2, 'gen', 'tool/gen/index', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', '2021-05-23 10:02:51', '', NULL, '代码生成菜单'),
	(116, '系统接口', 3, 3, 'swagger', 'tool/swagger/index', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', '2021-05-23 10:02:51', '', NULL, '系统接口菜单'),
	(500, '操作日志', 108, 1, 'operlog', 'monitor/operlog/index', 1, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', 'admin', '2021-05-23 10:02:51', '', NULL, '操作日志菜单'),
	(501, '登录日志', 108, 2, 'logininfor', 'monitor/logininfor/index', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor', 'admin', '2021-05-23 10:02:51', '', NULL, '登录日志菜单'),
	(1001, '用户查询', 100, 1, '', '', 1, 0, 'F', '0', '0', 'system:user:query', '#', 'admin', '2021-05-23 10:02:51', '', NULL, ''),
	(1002, '用户新增', 100, 2, '', '', 1, 0, 'F', '0', '0', 'system:user:add', '#', 'admin', '2021-05-23 10:02:51', '', NULL, ''),
	(1003, '用户修改', 100, 3, '', '', 1, 0, 'F', '0', '0', 'system:user:edit', '#', 'admin', '2021-05-23 10:02:51', '', NULL, ''),
	(1004, '用户删除', 100, 4, '', '', 1, 0, 'F', '0', '0', 'system:user:remove', '#', 'admin', '2021-05-23 10:02:51', '', NULL, ''),
	(1005, '用户导出', 100, 5, '', '', 1, 0, 'F', '0', '0', 'system:user:export', '#', 'admin', '2021-05-23 10:02:51', '', NULL, ''),
	(1006, '用户导入', 100, 6, '', '', 1, 0, 'F', '0', '0', 'system:user:import', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1007, '重置密码', 100, 7, '', '', 1, 0, 'F', '0', '0', 'system:user:resetPwd', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1008, '角色查询', 101, 1, '', '', 1, 0, 'F', '0', '0', 'system:role:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1009, '角色新增', 101, 2, '', '', 1, 0, 'F', '0', '0', 'system:role:add', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1010, '角色修改', 101, 3, '', '', 1, 0, 'F', '0', '0', 'system:role:edit', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1011, '角色删除', 101, 4, '', '', 1, 0, 'F', '0', '0', 'system:role:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1012, '角色导出', 101, 5, '', '', 1, 0, 'F', '0', '0', 'system:role:export', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1013, '菜单查询', 102, 1, '', '', 1, 0, 'F', '0', '0', 'system:menu:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1014, '菜单新增', 102, 2, '', '', 1, 0, 'F', '0', '0', 'system:menu:add', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1015, '菜单修改', 102, 3, '', '', 1, 0, 'F', '0', '0', 'system:menu:edit', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1016, '菜单删除', 102, 4, '', '', 1, 0, 'F', '0', '0', 'system:menu:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1017, '部门查询', 103, 1, '', '', 1, 0, 'F', '0', '0', 'system:dept:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1018, '部门新增', 103, 2, '', '', 1, 0, 'F', '0', '0', 'system:dept:add', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1019, '部门修改', 103, 3, '', '', 1, 0, 'F', '0', '0', 'system:dept:edit', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1020, '部门删除', 103, 4, '', '', 1, 0, 'F', '0', '0', 'system:dept:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1021, '岗位查询', 104, 1, '', '', 1, 0, 'F', '0', '0', 'system:post:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1022, '岗位新增', 104, 2, '', '', 1, 0, 'F', '0', '0', 'system:post:add', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1023, '岗位修改', 104, 3, '', '', 1, 0, 'F', '0', '0', 'system:post:edit', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1024, '岗位删除', 104, 4, '', '', 1, 0, 'F', '0', '0', 'system:post:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1025, '岗位导出', 104, 5, '', '', 1, 0, 'F', '0', '0', 'system:post:export', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1026, '字典查询', 105, 1, '#', '', 1, 0, 'F', '0', '0', 'system:dict:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1027, '字典新增', 105, 2, '#', '', 1, 0, 'F', '0', '0', 'system:dict:add', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1028, '字典修改', 105, 3, '#', '', 1, 0, 'F', '0', '0', 'system:dict:edit', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1029, '字典删除', 105, 4, '#', '', 1, 0, 'F', '0', '0', 'system:dict:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1030, '字典导出', 105, 5, '#', '', 1, 0, 'F', '0', '0', 'system:dict:export', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1031, '参数查询', 106, 1, '#', '', 1, 0, 'F', '0', '0', 'system:config:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1032, '参数新增', 106, 2, '#', '', 1, 0, 'F', '0', '0', 'system:config:add', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1033, '参数修改', 106, 3, '#', '', 1, 0, 'F', '0', '0', 'system:config:edit', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1034, '参数删除', 106, 4, '#', '', 1, 0, 'F', '0', '0', 'system:config:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1035, '参数导出', 106, 5, '#', '', 1, 0, 'F', '0', '0', 'system:config:export', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1036, '公告查询', 107, 1, '#', '', 1, 0, 'F', '0', '0', 'system:notice:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1037, '公告新增', 107, 2, '#', '', 1, 0, 'F', '0', '0', 'system:notice:add', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1038, '公告修改', 107, 3, '#', '', 1, 0, 'F', '0', '0', 'system:notice:edit', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1039, '公告删除', 107, 4, '#', '', 1, 0, 'F', '0', '0', 'system:notice:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1040, '操作查询', 500, 1, '#', '', 1, 0, 'F', '0', '0', 'monitor:operlog:query', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1041, '操作删除', 500, 2, '#', '', 1, 0, 'F', '0', '0', 'monitor:operlog:remove', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1042, '日志导出', 500, 4, '#', '', 1, 0, 'F', '0', '0', 'monitor:operlog:export', '#', 'admin', '2021-05-23 10:02:52', '', NULL, ''),
	(1043, '登录查询', 501, 1, '#', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:query', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1044, '登录删除', 501, 2, '#', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:remove', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1045, '日志导出', 501, 3, '#', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:export', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1046, '在线查询', 109, 1, '#', '', 1, 0, 'F', '0', '0', 'monitor:online:query', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1047, '批量强退', 109, 2, '#', '', 1, 0, 'F', '0', '0', 'monitor:online:batchLogout', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1048, '单条强退', 109, 3, '#', '', 1, 0, 'F', '0', '0', 'monitor:online:forceLogout', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1049, '任务查询', 110, 1, '#', '', 1, 0, 'F', '0', '0', 'monitor:job:query', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1050, '任务新增', 110, 2, '#', '', 1, 0, 'F', '0', '0', 'monitor:job:add', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1051, '任务修改', 110, 3, '#', '', 1, 0, 'F', '0', '0', 'monitor:job:edit', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1052, '任务删除', 110, 4, '#', '', 1, 0, 'F', '0', '0', 'monitor:job:remove', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1053, '状态修改', 110, 5, '#', '', 1, 0, 'F', '0', '0', 'monitor:job:changeStatus', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1054, '任务导出', 110, 7, '#', '', 1, 0, 'F', '0', '0', 'monitor:job:export', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1055, '生成查询', 115, 1, '#', '', 1, 0, 'F', '0', '0', 'tool:gen:query', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1056, '生成修改', 115, 2, '#', '', 1, 0, 'F', '0', '0', 'tool:gen:edit', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1057, '生成删除', 115, 3, '#', '', 1, 0, 'F', '0', '0', 'tool:gen:remove', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1058, '导入代码', 115, 2, '#', '', 1, 0, 'F', '0', '0', 'tool:gen:import', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1059, '预览代码', 115, 4, '#', '', 1, 0, 'F', '0', '0', 'tool:gen:preview', '#', 'admin', '2021-05-23 10:02:53', '', NULL, ''),
	(1060, '生成代码', 115, 5, '#', '', 1, 0, 'F', '0', '0', 'tool:gen:code', '#', 'admin', '2021-05-23 10:02:53', '', NULL, '');

INSERT INTO "sys_notice" ("notice_id", "notice_title", "notice_type", "notice_content", "status", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, '温馨提醒：2018-07-01 yadmin新版本发布啦', '2', '新版本内容', '0', 'admin', '2021-05-23 10:02:56', NULL, NULL, '管理员'),
	(2, '维护通知：2018-07-01 yadmin系统凌晨维护', '1', '维护内容', '0', 'admin', '2021-05-23 10:02:56', NULL, NULL, '管理员');

INSERT INTO "sys_post" ("post_id", "post_code", "post_name", "post_sort", "status", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, 'ceo', '董事长', 1, '0', 'admin', '2021-05-23 10:02:50', '', NULL, ''),
	(2, 'se', '项目经理', 2, '0', 'admin', '2021-05-23 10:02:50', '', NULL, ''),
	(3, 'hr', '人力资源', 3, '0', 'admin', '2021-05-23 10:02:50', '', NULL, ''),
	(4, 'user', '普通员工', 4, '0', 'admin', '2021-05-23 10:02:50', '', NULL, ''),
	(5, 'cfo', '首任安全官', 5, '0', 'admin', '2021-06-06 11:07:40', 'admin', NULL, NULL);

INSERT INTO "sys_role" ("role_id", "role_name", "role_key", "role_sort", "data_scope", "menu_check_strictly", "dept_check_strictly", "status", "del_flag", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, '超级管理员', 'admin', 1, '1', 1, 1, '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL, '超级管理员'),
	(2, '普通角色', 'common', 2, '2', 1, 1, '0', '0', 'admin', '2021-05-23 10:02:50', '', NULL, '普通角色');

INSERT INTO "sys_role_dept" ("role_id", "dept_id") VALUES
	(2, 100),
	(2, 101),
	(2, 105);

INSERT INTO "sys_role_menu" ("role_id", "menu_id") VALUES
	(2, 1),
	(2, 2),
	(2, 3),
	(2, 100),
	(2, 101),
	(2, 102),
	(2, 103),
	(2, 104),
	(2, 105),
	(2, 106),
	(2, 107),
	(2, 108),
	(2, 109),
	(2, 110),
	(2, 111),
	(2, 112),
	(2, 113),
	(2, 114),
	(2, 115),
	(2, 116),
	(2, 500),
	(2, 501),
	(2, 1000),
	(2, 1001),
	(2, 1002),
	(2, 1003),
	(2, 1004),
	(2, 1005),
	(2, 1006),
	(2, 1007),
	(2, 1008),
	(2, 1009),
	(2, 1010),
	(2, 1011),
	(2, 1012),
	(2, 1013),
	(2, 1014),
	(2, 1015),
	(2, 1016),
	(2, 1017),
	(2, 1018),
	(2, 1019),
	(2, 1020),
	(2, 1021),
	(2, 1022),
	(2, 1023),
	(2, 1024),
	(2, 1025),
	(2, 1026),
	(2, 1027),
	(2, 1028),
	(2, 1029),
	(2, 1030),
	(2, 1031),
	(2, 1032),
	(2, 1033),
	(2, 1034),
	(2, 1035),
	(2, 1036),
	(2, 1037),
	(2, 1038),
	(2, 1039),
	(2, 1040),
	(2, 1041),
	(2, 1042),
	(2, 1043),
	(2, 1044),
	(2, 1045),
	(2, 1046),
	(2, 1047),
	(2, 1048),
	(2, 1049),
	(2, 1050),
	(2, 1051),
	(2, 1052),
	(2, 1053),
	(2, 1054),
	(2, 1055),
	(2, 1056),
	(2, 1057),
	(2, 1058),
	(2, 1059),
	(2, 1060);

INSERT INTO "sys_user" ("user_id", "dept_id", "user_name", "nick_name", "user_type", "email", "phonenumber", "sex", "avatar", "password", "status", "del_flag", "login_ip", "login_date", "create_by", "create_time", "update_by", "update_time", "remark") VALUES
	(1, 103, 'admin', 'yadmin', '00', 'ry@163.com', '15888888888', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', '2021-09-28 22:23:52', 'admin', '2021-05-23 10:02:50', '', '2021-09-28 22:23:52', '管理员'),
	(2, 105, 'ry', 'yadmin', '00', 'ry@qq.com', '15666666666', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', '2021-05-23 10:02:50', 'admin', '2021-05-23 10:02:50', '', NULL, '测试员');

INSERT INTO "sys_user_post" ("user_id", "post_id") VALUES
	(1, 1),
	(2, 2);

INSERT INTO "sys_user_role" ("user_id", "role_id") VALUES
	(1, 1),
	(2, 2);
